<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>个人中心 - 个人选股系统 V5.87</title>
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <script src="/js/jquery-1.12.4.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script>
        $(document).ready(function () {

            $("input[name='toDel']").each(function () {
                let currentAdd = $(this);
                currentAdd.click(function () {
                    let code = $(this).attr("systemIdValue");
                    // alert("/del/" + code + ".html");
                    $.get("/del/" + code + ".html", function (data, status) {
                        alert("数据: " + data + "\n状态: " + status);
                    });
                    window.location.reload()
                });
            });
        });
    </script>

    <script>

        $.get('/center_data.html', function (data) {
            console.log(data)
            let data_arr = data;
            let $table = $('table')
            for (let i = 0; i < data_arr.length; i++) {
                let data_obj = data_arr[i]
                let row_str = '<tr>' +
                    '<td>' + data_obj.code + '</td>' +
                    '<td>' + data_obj.short + '</td>' +
                    '<td>' + data_obj.chg + '</td>' +
                    '<td>' + data_obj.turnover + '</td>' +
                    '<td>' + data_obj.highs + '</td>' +
                    '<td>' + data_obj.price + '</td>' +
                    '<td>' + data_obj.note_info + '</td>' +

                    '<td>'
                '<a type="button" class="btn btn-default btn-xs" href="/update/000426.html"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> 修改 </a>' + '</td>' +
                '<td>' +
                '<input type="button" value="删除" id="toDel" name="toDel" systemidvaule="000426">' +
                '</td>' +
                '</tr>';
                $table.append(row_str)
            }

        }, 'json').error(function () {
            $table.append('<td>未读取到数据</td>')
        })

    </script>
    <script>
        // 获取要添加内容的目标标签
        var $table = $('table');
        $.get('/center_data.html', function (data) {
            // 将取得的数据转换为数组
            let data_array = Array(data);
            // 遍历数组，并将每条数据转换为js对象，拼接到格式字符中
            for (let i = 0; i < data_array.length; i++) {
                let data_obj = data_array[i];
                let row_str = '<tr>' +
                    '<td>' + data_obj.code + '</td> ' +
                    '<td>' + data_obj.short + '</td> ' +
                    '<td>' + data_obj.chg + '</td> ' +
                    '<td>' + data_obj.turnover + '</td> ' +
                    '<td>' + data_obj.price + '</td> ' +
                    '<td>' + data_obj.highs + '</td> ' +
                    '<td>' + data_obj.note_info + '</td> ' +
                    '<td> ' +
                    '<a type="button" class="btn btn-default btn-xs" href="/update/000426.html"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> 修改 </a> ' +
                    '</td> ' +
                    '<td> ' +
                    '<input type="button" value="删除" id="toDel" name="toDel" systemidvaule="000426"> ' +
                    '</td> ' +
                    '</tr>'
                $table.append(row_str)
            }
        }, 'json').error(function () {
            $table.append('<td>未读取到数据！</td>')
        })
    </script>
</head>

<body>
<div class="navbar navbar-inverse navbar-static-top ">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle" data-toggle="collapse" data-target="#mymenu">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a href="#" class="navbar-brand">选股系统</a>
        </div>
        <div class="collapse navbar-collapse" id="mymenu">
            <ul class="nav navbar-nav">
                <li><a href="/index.html">股票信息</a></li>
                <li class="active"><a href="">个人中心</a></li>
            </ul>

        </div>
    </div>
</div>
<div class="container">

    <div class="container-fluid">

        <table class="table table-hover">
            <tr>
                <th>股票代码</th>
                <th>股票简称</th>
                <th>涨跌幅</th>
                <th>换手率</th>
                <th>最新价(元)</th>
                <th>前期高点</th>
                <th style="color:red">备注信息</th>
                <th>修改备注</th>
                <th>del</th>
            </tr>
            {%content%}
        </table>
    </div>
</div>
</body>
</html>            
